package com.tech.zhidengxian.model.dto.result;


public class ReturnResultUtils<T>{

    /***
     * 成功 不带数据
     * @return  返回状态码与状态信息
     */
    public static <T>ReturnResult<T> returnSuccess(){
        ReturnResult returnResult=new ReturnResult();
        returnResult.setCode(ResponseCode.SUCCESS);
        returnResult.setMessage("success");
        return returnResult;
    }
    /***
     * 成功 带数据
     * @return  返回状态码,状态信息与数据
     */
    public static <T>ReturnResult<T> returnSuccess(Object data){
        ReturnResult returnResult=new ReturnResult();
        returnResult.setCode(ResponseCode.SUCCESS);
        returnResult.setMessage("success");
        returnResult.setSuccess(true);
        returnResult.setData(data);
        return returnResult;
    }
    /***
     * 失败
     * @return  返回状态码与状态信息
     */
    public static <T>ReturnResult<T> returnFail(ResponseCode code, String message){
        ReturnResult returnResult=new ReturnResult();
        returnResult.setCode(code);
        returnResult.setMessage(message);
        returnResult.setSuccess(false);
        return returnResult;
    }
}

